package cn.uniqueinfo.dp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author:朱元勋
 * @mail:395910063@qq.com
 * @date:2019-01-04 09:43:43
 * @description: api文档生成
 * 在浏览器输入：http://${host}:${port}/doc.html
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket controllerRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).groupName("控制器").select().apis(RequestHandlerSelectors.basePackage("cn.uniqueinfo.dp.controller")).paths(PathSelectors.any()).build();
    }

    @Bean
    public Docket modelRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).groupName("vo").select().apis(RequestHandlerSelectors.basePackage("cn.uniqueinfo.dp.vo")).paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("优科开发平台Apis").description("swagger RESTful APIs").termsOfServiceUrl("http://www.unique-info.cn/").contact("395910063@qq.com").version("0.0.1").build();
    }
}
